package General;

import java.io.*;

public class ProcessUtils {
    private BufferedInputStream inputStream;
	private BufferedInputStream errorStream;

    public static synchronized ProcessUtils call(String cmd, String path) throws IOException {
		ProcessUtils util = new ProcessUtils();
		Process lastProcess = Runtime.getRuntime().exec(cmd, null, new File(path));
		util.errorStream = new BufferedInputStream(lastProcess.getErrorStream());
		util.inputStream = new BufferedInputStream(lastProcess.getInputStream());
        //print(util.inputStream);
		return util;
	}

    /*public static void print(BufferedInputStream bis) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(bis)  );
        String line;
        while((line=br.readLine())!= null) {
            System.out.println(line);
        }
    }*/

    public BufferedInputStream getErrorStream() {
		return errorStream;
	}

    public BufferedInputStream getInputStream() {
		return inputStream;
	}
}
